package AspectoLog;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Calendar;
import java.util.GregorianCalendar;

import javax.sql.rowset.Joinable;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;

public class ArqLog {

	String nomeArq ="";
	String nomeJogador = "";
		
	public ArqLog(String nomeArq){
		this.nomeArq = nomeArq;	
	}
	
	public void iniciar(){
		arquivar("**INICIO**");
	}
	
	public void arquivar(String info){
		try {
			BufferedWriter out = new BufferedWriter(
											new FileWriter(nomeArq, true));
			out.write("\n" + getHora() + " - " + info+ "\n" +"\n"+ "\n");
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	void arquivar(JoinPoint info ){
		Signature sig = info.getStaticPart().getSignature();
		String classe = sig.getDeclaringTypeName();
		String metodo = sig.getName();
		String dados = classe + metodo;
		arquivar(dados);
	}
	
	String getHora(){
		Calendar time = new GregorianCalendar();
		return time.getTime().toString();
	}

	
	
} //fim da classe
